#ifndef _747ENGINE_H_
#define _747ENGINE_H_

#include <SFML\System.hpp>
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include <SFML\Network.hpp>

#include <iostream>
#include <string>
#include <fstream>

#include "EntityManager.h"
#include "TextureManager.h"
#include "StateManager.h"
#include "FontManager.h"

extern bool preInit();
extern bool postInit();

extern void game_update();
extern void game_draw();

extern void onKeyPress(int key);
extern void onKeyRelease(int key);

namespace Engine
{
	enum logType
	{
		WARNING,
		ERROR,
		HIGH,
		LOW,
		MID,
	};
	class Engine
	{
	public:
		bool init();
		void run();
		void close();

		//Needs to be used in the preInit function...
		void setSettings(std::string windowTitle, int wHeight, int wWidth, bool isFullscreen=false, int ups=60, int fps=60);

		std::string getVersion(){return this->version;}

		sf::RenderWindow* getRenderWindow(){return &this->window;}

		//getting the different managers
		TextureManager* getTextureManager(){return textureManager;}
		EntityManager*	getEntityManager(){return entityManager;}
		StateManager*	getStateManager(){return stateManager;}

		//check if the game closed or not...
		bool getRunning(){return running;}
		void setRunning(bool ir){running = ir;}

		void log(std::string message, int type);
	private:
		Engine();

		void update();
		void draw();

		void gameLoop();
		void eventHandler(sf::Event Event);

		sf::Clock drawTimer;
		sf::Clock updateTimer;

		sf::RenderWindow window;

		std::string version;
		std::string windowTitle;

		int wHeight, wWidth;

		bool isFullscreen;
		bool running;

		int ups;	//updates per second
		int fps;	//frames per second

	protected:
	};

	Engine *g_engine;
}

#endif